#pragma once
#ifndef __HUFFMAN_H__
#define __HUFFMAN_H__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//haffman 树的结构
typedef struct __huffmanTreeNode
{
    unsigned int weight; //叶子结点权值，只有出现或者不出现，大于等于0，非负数，下同
    unsigned int parent; //指向双亲节点的下标，非负数，下同
    unsigned int lchild; //指向左孩子节点的下标，非负数，下同
    unsigned int rchild; //指向右孩子节点的小标，非负数，下同
} htNode, huffmanTree, HTNode;

typedef char huffmanCode;

typedef struct _func_huffmanTree
{
    huffmanTree *(*buildHTree)(unsigned int *, unsigned int);
    void (*printHTree)(huffmanTree *, unsigned int);
    void (*destoryHTree)(huffmanTree *);
    huffmanCode *(*buildHCode)(huffmanTree *, unsigned int, unsigned int);
    huffmanCode **(*getHCode)(huffmanTree *, unsigned int);
    void (*destoryHCode)(huffmanCode **);
    void (*printHCode)(huffmanCode **);
    int (*toHcode)(huffmanCode **, char[], unsigned int, char *, char **);
    int (*toString)(huffmanTree *, char[], unsigned int, char *, char **);
} func_huffmanTree;

extern func_huffmanTree fhuffmanTree;

#endif
